package com.controller;

import com.pojo.Member;
import com.server.impl.AssessServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description：消息管理
 */
@Controller
@RequestMapping("msg")
public class MsgController {
    @Resource
    AssessServiceImpl assessService;

    @RequestMapping(value ="/guestbook",method = RequestMethod.GET)
    public String guestbook(Model model){
        List<Member> assessList=assessService.getassessList();
        model.addAttribute("assessList",assessList);
        return "pages/Guestbook" ;
    }

    /*@RequestMapping(value ="/feedback",method = RequestMethod.GET)
    public String index2(){
        return "pages/Feedback" ;
    }*/

    @RequestMapping("/deleteByID")
    public String deleteByID(int pj_id)
    {
        assessService.deleteById(pj_id);

        return "/pages/Guestbook";
    }
    /*模糊查找*/
    @RequestMapping("/findpjcontext")
    @ResponseBody
    public ModelAndView findpjcontext(String pj_context) {
        //1.调用service方法
        List<Member> assessList = assessService.findpjcontext(pj_context);
        //2.实例化一个ModelAndView对象
        ModelAndView mv=new ModelAndView();
        mv.addObject("assessList",assessList);
        mv.setViewName("/pages/Guestbook");
        return mv;

    }
}
